import request from '@/utils/request';

export async function queryDaily(params) {
  return request('/api/finance/stats/getByPage', {
    params,
  });
}

export async function queryDailyStatistics(params) {
  return request('/api/finance/stats/statsTotalCount', {
    params,
  });
}

/**
 * 每月出货金额,出货平米数，出货数量
 * @param params
 * @returns {Promise<any>}
 */
export async function statsAmountByMonth(params) {
  return request('/api/finance/stats/statsAmountByMonth', {
    params,
  });
}

/**
 * 统计占比信息，产品维度
 * @param params
 * @returns {Promise<any>}
 */
export async function statsRatioByProduct(params) {
  return request('/api/finance/stats/statsRatioByProduct', {
    params,
  });
}

/**
 * 收款查询
 * @param params
 * @returns {Promise<any>}
 */
export async function queryFinanceReceivable(params) {
  return request('/api/finance/receivable/selectByPage', {
    params,
  });
}

/**
 * 新增收款
 * @param params
 * @returns {Promise<any>}
 */
export async function addFinanceReceivable(params) {
  return request('/api/finance/receivable/addReceivedRecord', {
    method: 'POST',
    data: { ...params },
  });
}

/**
 * 完结收款
 * @param params
 * @returns {Promise<any>}
 */
export async function finishReceivable(params) {
  return request(`/api/finance/receivable/settled/${params.pkId}`, {
    method: 'PUT',
  });
}


/**
 * 根据应收款id查询应收款明细
 * @param params
 * @returns {Promise<any>}
 */
export async function queryReceivableDetail(params) {
  return request(`/api/finance/receivable/receivableDetail/${params.custId}/${params.dataMonth}`, {
    params,
  });
}

/**
 * 根据应收款客户和账期查询已收款明细
 * @param params
 * @returns {Promise<any>}
 */
export async function queryReceivedDetail(params) {
  return request(`/api/finance/receivable/receivedDetail/${params.custId}/${params.dataMonth}`, {
    params,
  });
}

/**
 * 根据应收款客户和账期查询已收款明细
 * @param params
 * @returns {Promise<any>}
 */
export async function receivableDetailByOrder(params) {
  return request(`/api/finance/receivable/receivableDetailByOrder/${params.orderId}/${params.dataMonth}`, {
    params,
  });
}

/**
 * 付款查询
 * @param params
 * @returns {Promise<any>}
 */
export async function queryFinancePayable(params) {
  return request('/api/finAccountPayable/selectByPage', {
    params,
  });
}

/**
 * 新增付款
 * @param params
 * @returns {Promise<any>}
 */
export async function addFinancePayable(params) {
  return request('/api/finAccountPaidDetail', {
    method: 'POST',
    data: { ...params },
  });
}

/**
 * 完结付款
 * @param params
 * @returns {Promise<any>}
 */
export async function finishFinancePayable(params) {
  return request(`/api/finAccountPayable/settled/${params.pkId}`, {
    method: 'PUT',
  });
}

/**
 * 应付款明细查询
 * @param params
 * @returns {Promise<any>}
 */
export async function queryFinancePayableDetail(params) {
  return request(`/api/finAccountPayable/detail/${params.requestId}`, {
  });
}

/**
 * 应付款明细查询
 * @param params
 * @returns {Promise<any>}
 */
export async function queryFinancePaidDetail(params) {
  return request(`/api/finAccountPaidDetail/selectByRequestId/${params.requestId}`, {
  });
}
